<script setup>
// 子组件传递消息给父组件
const emit = defineEmits(['change']);
const buy = () => {
    emit('change', 5);
};
// 

// 父组件传递消息给子组件
const props = defineProps({
    car: {
        type: String,
        default: 'this is son msg',
    },
    money: {
        type: Number,
        default: 1000,
    },
});

</script>

<template>
    <div class="son">我是子组件  -- {{ car }} -- {{ money }}</div>
    <button @click="buy">花钱</button>
</template>

<style scoped>
.son {
    border: 1px solid #000;
    padding: 10px;
    color: #000;
    background-color: pink;
}
</style>